package com.example.fourtestapp.dbhelper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.example.fourtestapp.entity.BillInfo;
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;

import java.sql.SQLException;

public class DBhelper extends OrmLiteSqliteOpenHelper {
    public DBhelper(Context context) {
        super(context, "FourTest.db", null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase, ConnectionSource connectionSource) {
        try{
            TableUtils.createTable(connectionSource, BillInfo.class);
        }catch (Exception e){

        }

    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, ConnectionSource connectionSource, int i, int i1) {

    }
    Dao<BillInfo ,Integer> billInfoDao = null;
    public  Dao<BillInfo ,Integer> getbilDao() throws SQLException {
        if (billInfoDao==null){
            billInfoDao=getDao(BillInfo.class);
        }
        return billInfoDao;
    }
}
